package com.example.demo.database.migration.system;

import com.example.demo.database.services.base.Migrator;
import com.example.demo.database.services.base.SqlCompiler;

public class TaskMigrator extends Migrator {

    @Override
    public void up(SqlCompiler sqlCompiler) {
        sqlCompiler.create("tasks", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("number").nullable().comment("创建者学号");
            columnGenerator.string("clazz").nullable().comment("运行的类");
            columnGenerator.longtext("param").nullable().comment("执行参数");
            columnGenerator.string("now").nullable().comment("当前进度");
            columnGenerator.string("max").nullable().comment("最大进度");
            columnGenerator.string("result").nullable().comment("返回值");
            columnGenerator.string("status").nullable().comment("运行状态");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });
    }

    @Override
    public void down(SqlCompiler sqlCompiler) {
        sqlCompiler.dropIfExists("tasks");
    }
}
